var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2BundleManager = require("BundleManager");
var $2ExcelManager = require("ExcelManager");
var $2PlantMgr = require("PlantMgr");
var $2UserDataManager = require("UserDataManager");
var $2KDefine = require("KDefine");
var $2PlantBase = require("PlantBase");
var d = cc._decorator.ccclass;
var def_Plant21 = /* */function (_c$default) {
  babel_inherits(h, _c$default);
  var _super63 = babel_createSuper(h);
  function h() {
    babel_classCallCheck(this, h);
    return _super63.apply(this, arguments);
  }
  babel_createClass(h, [{
    key: "onLoad",
    value: function onLoad() {
      this.regState($2KDefine.State.wait, this.stateWait);
      this.regState($2KDefine.State.waiting, this.stateWait);
      this.regState($2KDefine.State.hurt, this.stateHurt);
      this.regState($2KDefine.State.hurting, this.stateHurt);
      this.regState($2KDefine.State.dead, this.stateDead);
      this.regState($2KDefine.State.deading, this.stateDead);
      this.node.getComponent(cc.BoxCollider).enabled = false;
    }
  }, {
    key: "stateWait",
    value: function stateWait(e) {
      if (this.state === $2KDefine.State.wait) {
        this.state = $2KDefine.State.waiting;
        this.dragon.setAnimation(0, "daiji", true);
      }
    }
  }, {
    key: "stateHurt",
    value: function stateHurt(e) {
      if (this.state == $2KDefine.State.hurt) {
        this.state = $2KDefine.State.hurting;
        this.dragon.setAnimation(0, "shouji", true);
      }
    }
  }, {
    key: "onCollisionEnter",
    value: function onCollisionEnter(e, t) {
      !this.inUse || this.hp <= 0 || e.tag == $2KDefine.Tag.zombie && this.setState($2KDefine.State.hurt);
    }
  }, {
    key: "onCollisionExit",
    value: function onCollisionExit(e, t) {
      !this.inUse || this.hp <= 0 || e.tag === $2KDefine.Tag.zombie && this.setState($2KDefine.State.wait);
    }
  }, {
    key: "reset",
    value: function reset(e, t) {
      var _this138 = this;
      this.dragon = this.node.getChildByName("p01").getComponent(sp.Skeleton);
      var a = $2ExcelManager.ExcelMgr.instance.GetExcelObject($2ExcelManager.TableName.plantTable)[e];
      this.inUse = false;
      this.attDistance = a.attDistance;
      this.pTime = 0;
      this.id = a.id;
      this.attackCD = a.attackCD;
      this.simpleDamage = a.simpleDamage;
      this.hitSound = a.hitSound;
      this.shootSound = a.shootSound;
      this.hp = a.damage[$2UserDataManager.default.instance.getPlantLevel(this.id) - 1][1] * this.simpleDamage;
      this.shootDelay = a.shootDelay;
      this.cost = a.cost[$2UserDataManager.default.instance.getPlantLevel(this.id) - 1][1];
      this.bulletId = a.bullet;
      this.dragonName = a.dragonName;
      this.skillCD = a.skillCD;
      this.remainCD = this.skillCD;
      this.shootPo = new cc.Vec2(a.shootPo[0], a.shootPo[1]);
      this.skillPos = new cc.Vec2(a.skillPos[0], a.skillPos[1]);
      this.attackNums = a.attackNums;
      this.skillNums = a.skillNums;
      this.attackSpeed = a.attackSpeed;
      this.skillDamage = a.skillDamage;
      this.skillbullet = a.skillbullet;
      if (!t) {
        if ($2BundleManager.default.instance.getBundleRes("Spine", $2PlantMgr.default.resPre + this.dragonName + "/" + this.dragonName, sp.SkeletonData)) {
          this.dragon.skeletonData = $2BundleManager.default.instance.getBundleRes("Spine", $2PlantMgr.default.resPre + this.dragonName + "/" + this.dragonName, sp.SkeletonData);
        } else {
          $2BundleManager.default.instance.loadBundleRes("Spine", $2PlantMgr.default.resPre + this.dragonName + "/" + this.dragonName, sp.SkeletonData, function () {
            _this138.dragon.skeletonData = $2BundleManager.default.instance.getBundleRes("Spine", $2PlantMgr.default.resPre + _this138.dragonName + "/" + _this138.dragonName, sp.SkeletonData);
          });
        }
      }
      a.skinName && this.dragon.setSkin(a.skinName);
      this.scale = a.scale;
    }
  }, {
    key: "checkTarget",
    value: function checkTarget() {
      return false;
    }
  }]);
  return h;
}($2PlantBase.default);
def_Plant21 = cc__decorate([d], def_Plant21);
exports.default = def_Plant21;